import { IStorage } from './type';
import { MinioStorage } from './minioStorage';
import { ObjectStorage } from './objectStorage';
import { configurationService } from '../../domain/service/configService';
export function initObjectStorageService(options?: IStorage): ObjectStorage {
  if (options) {
    if (options.type === 'minio') {
      return new MinioStorage(options.config);
    } 
    throw new Error(`unsupported object storage backend ${options.type}`);
  } else {
    const storageType = configurationService.config.storage.type;
    if (storageType === 'minio') {
      return new MinioStorage(configurationService.config.storage.config);
    } 
    throw new Error(`unsupported object storage backend ${storageType}`);
  }
}
export const objectStorageService = initObjectStorageService();